Parallelized magnitude comparator

ABSTRACT

A magnitude comparator suitable for use in a FIFO memory is modified to compare the magnitudes of two values more quickly. Bit comparators are divided into groups which generate compare output signals in parallel to one another, thereby reducing total magnitude comparator delay and resulting in faster operation. These compare output signals are fed into a control element which determines which compare output signal is allowed to pass through as the final compare output signal.

CROSS REFERENCE TO RELATED APPLICATIONS

The subject matter of the present application is related to copending U.S. application Ser. No. 07/860981, titled "Parallelized Borrow Look Ahead Subtractor", and copending U.S. application Ser. No. 07/876,851 titled "Parallelized Magnitude Comparator For Comparing A Binary Number to a Fixed Value", filed with the Application hereof on Apr. 30, 1992, both assigned to the assignee hereof, and both of which are herein incorporated by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates generally to integrated circuits, and more specifically to a magnitude comparator circuit.

2. Description of the Prior Art

Magnitude comparator circuits are used when it is necessary to determine the relationship between the magnitude of two numbers--whether a number is equal to, less than, or greater than another number in magnitude. Such circuits find a wide variety of uses in the electronics industry. For example, magnitude comparators are used in conjunction with subtractors to generate high speed flag logic for FIFO (First In First Out) memories. Magnitude comparator circuits are also used in arithmetic logic units (ALU's) found in personal computers (PCs) and other computers and by microprocessors for the execution of certain instructions.

Serial magnitude comparators are a common form of comparator circuits in the prior art. They have a number of individual bit comparators that together serially determine the magnitude of a number relative to another number. First, the least significant bits (LSBs) of the two numbers are compared before comparing the next bits, the LSB+1. This process continues serially until the most significant bits (MSBs) have been compared. The serial process can be quite consuming; at least 16 gate delays will be incurred for comparing two 16 bit words.

The individual bit comparators which comprise a serial magnitude comparator have four inputs: two inputs determined by the two bits to be compared, an input from the compare output of the previous magnitude comparator, and an input equal to the first bit of the two bits being compared. The compare output of a bit comparator is input to the subsequent bit comparator and reflects whether the magnitude of one bit is equal to, less than, or greater than the magnitude of the second bit. If the two bits being compared are equal, then the compare input is passed through the bit comparator as the compare output. If, however, the two bits are unequal in magnitude, then the input equal to the first bit of the two bits being compared is passed through as the compare output. This comparison process starts with the least significant bit (LSB) comparator and continues until the most significant bit (MSB) comparator finishes its comparison operation. The bit comparator with the highest order bit of difference determines the state of the final compare output.

The gate delays associated with serial magnitude comparators can have an adverse effect on overall system performance. In FIFO (First In First Out) memory applications, a magnitude comparator is often used in conjunction with a subtractor circuit to generate FIFO flag logic. A FIFO flag tells the user how full the FIFO is. Flag logic, which is dependent on the comparator and subtractor, must be generated quickly. If the magnitude comparator is slow, it will have an adverse affect on how quickly flag logic may be generated and overall FIFO performance will suffer. A fundamental way to enhance the speed at which FIFO flag logic is generated is to minimize propagation and gate delays associated with serial magnitude comparators. It would be desirable to accomplish this using current magnitude comparator design.

SUMMARY OF THE INVENTION

A magnitude comparator suitable for use in a FIFO memory is modified to compare the magnitudes of two values more quickly. Bit comparators are divided into groups which generate compare output signals in parallel to one another, thereby reducing total magnitude comparator delay and resulting in faster operation. These compare output signals are fed into a control element which determines which compare output signal is allowed to pass through as the final compare output signal.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features believed characteristic of the invention are set forth in the appended claims. The invention itself however, as well as a preferred mode of use, and further objects and advantages thereof, will best be understood by reference to the following detailed description of an illustrative embodiment when read in conjunction with the accompanying drawings, wherein:

FIG. 1 is a block diagram of a FIFO flag generation circuit according to the prior art;

FIG. 2 is a schematic diagram of a serial magnitude comparator utilized in the prior art;

FIG. 3 is a schematic diagram of a parallel magnitude comparator according to the present invention;

FIG. 4 is a schematic diagram of a tri-stateable gate according to the present invention.

DESCRIPTION OF THE PREFERRED EMBODIMENT

A FIFO is a First In First Out memory typically used in applications between machines which use data at different rates of speed: for instance, between a computer and a printer. The FIFO memory outputs its status through the use of a flag. Comparators are frequently used in FIFO memory circuits in conjunction with subtractors to generate FIFO flags. The flag outputs indicate that the FIFO is full, half full, and empty, for instance. In order to determine FIFO status, it is necessary to keep track of how many bits have been written in and how many bits have been read out of the FIFO. Also, it is necessary to know the relationship between the magnitude of two numbers and whether the magnitude of one number is equal to, less than, or greater than the magnitude of the second number. Comparing the magnitude of these numbers is accomplished through the use of a magnitude comparator circuit inside the FIFO.

Referring to FIG. 1, a block diagram of a FIFO Flag generation circuit according to the prior art is shown. The FIFO Flag has a counter block 1, a subtractor block 2, a comparator block 3, and a deglitch block 4. The write clock 5, the read clock 6, the write reset clock 7, and the read reset clock 8 are input signals to both the counter block 1 and the deglitch block 4. The counter block 1 takes these input signals and generates a write count 9 and a read count 10 which are input to the subtractor block 2 which in turn outputs a difference signal 11. This difference signal 11 and a program value 12 are input to the comparator block 3 which compares them in order to generate an output compare signal 13. As is well known in the art, the program value 12 is set to different values depending on the type of flag signal 14, such as empty, half full, or full, to be generated. Finally, the compare signal 13 as well as the write clock 5, the read clock 6, the write reset clock 7, and the read reset clock 8 are input to the deglitch block 4 which generates a flag output signal 14.

FIG. 2 shows a schematic diagram of a serial magnitude comparator 20 utilized in the prior art. The magnitude comparator 20 is responsible for determining the relationship between the magnitude of two numbers. The magnitude comparator 20 has a plurality of bit comparators 22, 24, 26, and 28 which determine the status of the relative magnitude of the two numbers being compared. The number of bit comparators needed is a function of the number of bits in the two numbers being compared. Each bit comparator compares a bit, at a certain bit position, from both numbers. For example, the magnitude status of the first bit to be compared, 40, is compared to that of the second bit 42 to determine if it is equal to, less than, or greater than the second bit 42. Every bit comparator has four inputs. The two bits to be compared, 40 and 42, are input to an exclusive OR gate 44, the output of which is input 36 of bit comparators 22, 24, 26 and 28; signal 36 is inverted to provide input 38. Input 38, which is simply the inverse of input 36, could easily be generated internal to the bit comparator, in which case it would not be an input signal. Other inputs to the bit comparators are the output of the previous bit comparator 30, and input 34, the first bit of the two bits being compared. Input 34 is different from program value 32 shown in FIG. 1. FIG. 2 shows two binary numbers being compared whereas FIG. 1 shows a binary number being compared with a fixed value represented by program value 32.

The bit comparators of FIG. 2 detect the relative magnitude of the two numbers being compared. Bit inputs 40 and 42 pass through an exclusive OR gate 44. If bits 40 and bit 42 are the same, then input 36 will be equal to 0 and input 38, which is the inverse of input 36, will be equal to 1. But if bit 40 and bit 42 are different in magnitude, then input 36 will be equal to 1 and input 38 will be equal to 0. Therefore, if bits 40 and 42 are different in magnitude, compare output 32 is equal to compare input 30. However, if bits 40 and 42 are different in magnitude, compare output 32 is equal to input 34. The truth table of Table 1 below shows the relationship between the two bits being compared, input 36, and output 32.

                  TABLE 1                                                          ______________________________________                                         Bit 40  Bit 42       Input 36 Output 32                                        ______________________________________                                         0       0            0        Input 30                                         0       1            1        Input 34                                         1       0            1        Input 34                                         1       1            0        Input 30                                         ______________________________________                                    

This table shows that when the two bits to be compared, 40 and 42, are different, then compare input 34 is passed out as compare output 32. Conversely, when bits 40 and 42 are the same in magnitude, the compare input from the previous bit comparator 30 is passed out as compare output 32. Compare input 30 of the initial bit comparator 22 is tied to a fixed value which can be V_(cc) or ground as shown in FIG. 2. Thus, if input bits 40 and 42 are the same, then a low will be passed to the compare output 32. In turn, bit comparator 24 receives a low input signal 30 and, if input bits 40 and 42 of bit comparator 24 have the same magnitude, compare output 32 will again be 0, passing out incoming compare input 30. This process starts with the least significant bit (LSB) comparator 22 and continues serially until the most significant bit (MSB) comparator 28 has finished its compare operation. Only when the magnitudes of the MSBs have been compared will a final compare output 32 be generated. The highest order bit comparator with bit difference determines the state of the final compare output 32 of bit comparator 28.

FIG. 2 shows that sixteen bit comparators are needed to compare two sixteen bit numbers. Since the process is serial, it can be quite time consuming to wait for a final compare output. For a sixteen bit comparison, at least sixteen gate delays must be incurred before a final compare output signal is forthcoming. This is applicable to the worst case scenarios where only the LSBs differ or where all sixteen bits being compared are equal in magnitude. It is desirable to speed up this serial comparison process since many comparator applications demand high speed performance.

FIG. 3 shows a schematic diagram of a parallel magnitude comparator according to the present invention. Bit comparators have the same inputs and output as shown in FIG. 2. However, the present invention differs in that the bit comparators are segmented into groups which operate independently of each other in parallel. Referring to FIG. 3, the bit comparators are divided into comparator groups 50, 60, 70, and 80. The inputs and outputs of each bit comparator are equal to those shown in FIG. 2. Input 36 is determined by passing the two bits to be compared through an exclusive OR gate, and input 38 is the inverse of input 36. Input 38 is the inverse of input 36 and could, therefore, be generated internal to the bit comparator and need not be an input at all. Input 34 is equal to the first bit of the two bits being compared. Compare output 32, as in FIG. 2, is dependent on the relative magnitude of the two bits being compared.

The truth table shown above for FIG. 2 is also applicable to FIG. 3. If input bit 36 is a logic high, the two bits compared are different relative to each other, and input 34 is passed out as the compare output 32. If, however, input bit 36 is a logic low, the two bits compared have the same magnitude relative to each other, and compare input 30 is simply passed out as the compare output 32. As an example, if each of the four bit comparators 52, 54, 56, and 58 of comparator group 50 compares bits that are equal to each other, then the logic low compare input 30 of initial bit comparator 52 will be passed through subsequent bit comparators 54, 56, and 58 until it is the compare output 59 of the comparator group. At this point, the logic low compare output signal 59 will be an input to control element 90. At all times, as in this example, output compare 59 of the comparator group 50 is equal to compare output 32 of the bit comparator having the highest order bit difference.

In a sixteen bit example, comparator group 50 compares the magnitude of the four least significant bits (LSBs) of two numbers. Comparator groups 60 and 70 compare the magnitude of bits 5-8 and 9-12, respectively, while comparator group 80 compares the magnitude of the most significant bits (MSBs), 13-16. Comparison of these bits occurs serially within the comparator groups, with comparator groups 50, 60, 70, and 80 operating in a parallel fashion to one another. Therefore, comparison of all sixteen bits occurs in the same amount of time required to compare four bits in the serial magnitude comparator of FIG. 2. Clearly this means an increase in performance for any system using a parallel magnitude comparator. One skilled in the magnitude comparator art will recognize that breaking the bit comparators into groups of four is only one of many ways to group the bit comparators.

The compare output signals 59, 69, 79, and 89 of each comparator group are inputs to the control element 90. Only one of these compare output signals, selected by control element 90, will be passed through the control element to be final compare output 100. Control element 90 has a plurality of transmission gates 92, 94, 96,and 98 each of which corresponds to one comparator group: 50, 60, 70, and 80, respectively. Each transmission gate has as inputs the compare output from the corresponding comparator group and an logic input determined by boolean equations. Transmission gate 92 has as its inputs compare output 59 of comparator group 50 and logic input 93. The logic inputs 93, 95, 97, and 99 ensure that only the compare output of the comparator group having the highest order bits with magnitude difference will be passed out of control element 90 as final compare output 100. If none of the bits are different, then compare output 59 of the lowest order comparator group 50 is passed through control element 90 as final compare output 100.

Logic inputs 93, 95, 97, and 99 are determined by the following equation: S_(N) =X_(N) +X_(N-1) +X_(N-2) +X_(N-3), where X_(N) is the result of exclusive ORing the two bits to be compared. Specifically, the logic inputs are as follows:

    Input 99=S.sub.16 =X.sub.16 +X.sub.15 +X.sub.14 +X.sub.13

    Input 97=S.sub.12 *S.sub.16 =(X.sub.12 +X.sub.11 +X.sub.10 +X.sub.9)*S.sub.16

    Input 95=S.sub.8 *S.sub.12 *S.sub.16 =(X.sub.8 +X.sub.7 +X.sub.6 +X.sub.5)*S.sub.12 *S.sub.16

    Input 93=S.sub.8 *S.sub.12 *S.sub.16

When one of the logic inputs 93, 95, 97, or 99 is high, its corresponding transmission gate turns on and allows the corresponding comparator group compare output, 59, 69, 79, or 89, to pass through the transmission gate. If, however, the logic input is low, its corresponding transmission gate turns off and does not allow the corresponding compare output signal to pass through the transmission gate. These equations guarantee that the compare output of the comparator group having the highest order of bit difference is passed out as final compare output 100. For instance, if two binary numbers have unequal magnitudes for bit 14 and also for bit 2, the logic inputs ensure that compare output 89 of comparator group 80 will be passed out as final compare output 100 since bit 14 is more significant than bit 2. Determination of logic inputs 93, 95, 97, and 99 occurs at the same time comparator groups 50, 60, 70, and 80 perform magnitude compare operations. This parallel operation allows the appropriate compare output 59, 69, 79, or 89 to be selected by control element 90 and passed out as final compare output 100 immediately after the comparator groups have completed comparison operations. Control element 90 adds little delay to the parallel magnitude comparator comparison time, since control element 90 finishes its operations prior to or at the same time group compare outputs 59, 69, 79, and 89 are ready to be passed through the control element 90.

The present invention as described in FIG. 3, would result in five gate delays: one gate delay for each magnitude comparator operating serially in a comparator group, such as bit comparators 52, 54, 56, and 58 in comparator group 50, and one gate delay for control element 90. The invention requires no buffering since the bit comparators are split into groups of four. This is a marked improvement over the serial magnitude comparator shown in FIG. 2 which results in at least 16 gate delays, one for each bit comparator. In the 16 bit example, buffering is needed to avoid the signal degradation which would occur from propagating through 16 serially connected bit comparators. The gate delay is even greater when buffering is used in the serial magnitude comparator. If an inverter were placed after every fourth bit comparator, four extra gate delays would be added for a total of 20 gate delays.

An alternative embodiment of the invention using a tri-stateable gate rather than a transmission gate is shown in FIG. 4. FIG. 4 shows a tri-stateable gate 140 with three inputs: INPUT, LOGIC INPUT and LOGIC INPUT. INPUT is the compare output signal from the corresponding comparator group and is analogous to group compare outputs 59, 69, 79, and 89 shown in FIG. 3. LOGIC INPUT is analogous to logic inputs 93, 95, 97, and 99 of FIG. 3; LOGIC INPUT is determined by the same S_(N) equations shown above. LOGIC INPUT is simply the inverse of LOGIC INPUT. The OUTPUT signal is determined by the state of the LOGIC INPUT signal. When LOGIC INPUT is a logic high, LOGIC INPUT is a logic low, and the LOGIC INPUT signal is passed through as the OUTPUT. When LOGIC INPUT is a logic low, LOGIC INPUT is a logic high, and tri-stateable gate 110 is effectively in a high impedance state and shuts off, allowing nothing to pass.

Four tri-stateable gates 140 would take the place of the four transmission gates shown in FIG. 3 and would both multiplex and buffer in the same stage. The outputs of these four pass gates would be wired together for a single final compare output 100. In this case, buffering would still not be required for the 16 bit parallel magnitude comparator shown in FIG. 3.

The parallelized magnitude comparator has been described in relation to a FIFO flag generation circuit. The magnitude comparator can also be used in a multitude of other applications such as in arithmetic logic units (ALUs) of computers where it is necessary to determine the magnitude of one number relative to that of a second number.

While the invention has been particularly shown and described with reference to two preferred embodiments, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention. 

What is claimed is:
 1. A magnitude comparator, comprising:a plurality of bit comparators, divided into comparator groups that each generate a comparator group output signal, wherein each of said bit comparators has a first binary bit input signal, a second binary bit input signal, a compare input signal and a compare output signal, and compares the magnitude between the first binary bit input signal and the second bit input signal and generates the compare output signal, wherein the compare input signal of each bit comparator is the compare output signal generated by the previous bit comparator and wherein the compare output signal of each bit comparator is provided as the compare input signal of the subsequent bit comparator; and a control element, having control input signals connected to the comparator group outputs of said comparator groups, which selects one of the comparator group outputs of said comparator groups to be output from said control element.
 2. The magnitude comparator of claim 1, wherein each said comparator group is independent from every other comparator group.
 3. The comparator group of claim 2, wherein said comparator groups compare a plurality of bits simultaneously.
 4. The comparator group of claim 2, wherein said comparator groups and said control element perform their respective functions simultaneously.
 5. The magnitude comparator of claim 1, wherein the compare input signal of the initial bit comparator is set to a predetermined level.
 6. The magnitude comparator of claim 1, wherein said first binary bit input signal is a one bit value determined by performing logic on a first bit and a second bit to be compared.
 7. The magnitude comparator of claim 6, wherein said second value input is equal to the value of the first bit to be compared.
 8. The magnitude comparator of claim 6, wherein the first bit and the second bit to be compared are a FIFO read count and a FIFO write count, respectively.
 9. The magnitude comparator of claim 1, wherein said control element determines which said comparator group contains the highest order bits which do not match.
 10. The control element of claim 9, wherein said control element has a plurality of gates each of which corresponds to one of said comparator groups.
 11. The control element of claim 10, wherein said control element has a plurality of transmission gates each of which corresponds to one of said comparator groups.
 12. The control element of claim 10, wherein said control element has a plurality of tri-stateable gates each of which corresponds to one of said comparator groups.
 13. The comparator of claim 10, wherein each said gate receives a first and a second value input which determines whether said gate will allow the first value input to be output from said gate.
 14. The gate of claim 13, wherein the first value input is the comparator group output from the corresponding said comparator group.
 15. The gate of claim 14, wherein the second value input is determined by whether the bits compared in the current said comparator group or higher order said comparator groups match.
 16. The gate of claim 13, wherein said gate is capable of not allowing said first value input of said gate to be output from said gate.
 17. The gate of claim 13, wherein only one of the plurality of gates may allow said first value input of said gate to be output from said gate.
 18. The control element of claim 10, wherein there are four said comparator groups each of which has four bit comparators.
 19. The control element of claim 18, wherein each of four said comparator groups corresponds to one said gate for a sixteen bit FIFO flag generation circuit.
 20. A method for comparing the magnitude between a first binary value input and a second value input, comprising the steps of:comparing the magnitude between a first value input and a second value input by grouping bit comparators into comparator groups which generate compare outputs which are input to a control element, wherein each bit comparator has a first binary bit input signal, a second binary bit input signal, a compare input signal and a compare output signal, and compares the magnitude between the first binary bit input signal and the second binary bit input signal and generates the compare output signal, wherein the compare input signal of each bit comparator is the compare output signal generated by the previous bit comparator and wherein the compare output signal of each bit comparator is provided as the compare input signal of the subsequent bit comparator; and generating a final compare output from said control element indicative of whether the magnitude of said first binary bit input signal is equal to, less than, or greater than the magnitude of said second binary bit input signal.
 21. The method of claim 20, wherein said comparator groups, which operate in parallel and independently of each other, generate compare outputs which are input to said control element.
 22. The method of claim 20, wherein said control element selects only one of said compare outputs to be output from said control element as a final compare output signal.
 23. The method of claim 20, wherein said comparator groups and said control element operate independently and in parallel with each other.
 24. The method of claim 20, wherein comparison of the magnitude between said first binary bit input signal and said second input signal is useful to generate a flag signal suitable for a FIFO.
 25. The magnitude comparator of claim 24, wherein when the first binary bit input signal is equal to the second binary bit input signal, the compare input signal is passed through the bit comparator as the compare output signal.
 26. The magnitude comparator of claim 24, wherein when the first binary bit input signal is not equal to the second binary bit input signal, the first binary bit input signal is passed through the bit comparator as the compare output signal. 